using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class simpleFootstep : MonoBehaviour
{  private AudioSource audioSource;
    // Start is called before the first frame update
    void Start()
    {
        audioSource = GetComponent<AudioSource>();
    }

    // Update is called once per frame
    void Update()
    {
        bool isPressingMoveKey = Input.GetKey(KeyCode.W) ||
                                 Input.GetKey(KeyCode.A) ||
                                 Input.GetKey(KeyCode.S) ||
                                 Input.GetKey(KeyCode.D);
        if (isPressingMoveKey && !audioSource.isPlaying)
        {
            audioSource.Play();
        }
        else if (!isPressingMoveKey && audioSource.isPlaying)
        {
            audioSource.Stop();
        }

    }
}
